package com.guoproject.ui;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.FrameLayout;
import android.widget.ImageView;

import com.guoproject.BaseActivity;
import com.guoproject.R;

public class DiscountActivity extends BaseActivity implements OnClickListener {
	// ============== 顶部 ===================

	// ============== 中部 ===================

	private static final String TAG = "DiscountActivity";
	// ============== 底部 ===================
	private ImageView im_bottom_plus;
	private FrameLayout fl_bottom_discount;
	private FrameLayout fl_bottom_concern;
	private FrameLayout fl_bottom_nutrition;
	private FrameLayout fl_bottom_more;
	private FrameLayout fl_tab_toolbar_plus;
	private int times = 2;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// 取消标题栏
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_discount);
		findViewById();
		initView();
	}

	@Override
	protected void findViewById() {
		// TODO Auto-generated method stub
		im_bottom_plus = (ImageView) findViewById(R.id.im_bottom_plus);
		im_bottom_plus.setBackgroundResource(R.drawable.tab_toolbar_plus);
		im_bottom_plus.setOnClickListener(this);
		// 底部
		fl_bottom_discount = (FrameLayout) findViewById(R.id.fl_bottom_discount);
		fl_bottom_concern = (FrameLayout) findViewById(R.id.fl_bottom_concern);
		fl_bottom_nutrition = (FrameLayout) findViewById(R.id.fl_bottom_nutrition);
		fl_bottom_more = (FrameLayout) findViewById(R.id.fl_bottom_more);
		fl_tab_toolbar_plus = (FrameLayout) findViewById(R.id.fl_tab_toolbar_plus);
		fl_bottom_more.setOnClickListener(this);
		fl_bottom_nutrition.setOnClickListener(this);
		fl_bottom_concern.setOnClickListener(this);
		fl_bottom_discount.setOnClickListener(this);
		fl_tab_toolbar_plus.setOnClickListener(this);
	}

	@Override
	protected void initView() {
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.fl_tab_toolbar_plus:
			Log.i(TAG, "fl_tab_toolbar_plus");
			if (times % 2 == 1) {
				im_bottom_plus
						.setBackgroundResource(R.drawable.tab_toolbar_plus);
				times += 1;

			} else if (times % 2 == 0) {
				im_bottom_plus
						.setBackgroundResource(R.drawable.tab_toolbar_plusback);
				times += 1;

			}
			break;
		case R.id.fl_bottom_discount:
			Log.i(TAG, "fl_bottom_discount");
			Intent discountIntent = new Intent(this,DiscountActivity.class);
			startActivity(discountIntent);
			finish();
			break;
		case R.id.fl_bottom_concern:
			Log.i(TAG, "fl_bottom_concern");
			Intent concernIntent = new Intent(this, ConcernActivity.class);
			startActivity(concernIntent);
			finish();
			break;
		case R.id.fl_bottom_nutrition:
			Intent nutritionIntent = new Intent(this, NutritionActivity.class);
			startActivity(nutritionIntent);
			Log.i(TAG, "fl_bottom_nutrition");
			finish();
			break;
		case R.id.fl_bottom_more:
			Intent moreIntent = new Intent(this, MoreActivity.class);
			startActivity(moreIntent);
			Log.i(TAG, "fl_bottom_more");
			finish();
			break;
		}

	}

}
